<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Test extends Test_Controller {

    function __construct ()
    {
        parent::__construct();
    }
     /**
     * 清除所有的cookie和session
     */
    public function clean_cs() {
        $this->load->helper('cookie');
        $this->session->unset_userdata("wechat_user");
        $this->session->unset_userdata("target_url");
        $this->session->unset_userdata("wechat_user_info");
        $uid=$this->session->userdata('user_id');
        $this->user_m->del_user_key_by_user_id($uid);
        $this->session->unset_userdata('user_id');
        setcookie('loveme', '', time() - 3600, '/', '', false, true);
        $this->session->sess_destroy();
        delete_cookie("machine_key");
        delete_cookie("qq_city");
        delete_cookie("qq_lat");
        delete_cookie("qq_lng");
        delete_cookie("user_referee");
        foreach ($_COOKIE as $key => $value) {
            setcookie($key, null);
        }
        pp("清楚缓存成功");exit();
    }
    public  function session(){
        pp($_SESSION);
    }

    public function login($referee = 0)
    {
        if($referee>0){
            if($refereeinfo = $this->user_m->get_user_by_user_id($referee)){
                $_COOKIE['user_referee'] = $referee;
                setcookie('user_referee', $referee, time() + 86500, '/', '', false, true);
            }
        }
        $this->load->view('login');
    }

}
